<form id="id_updateOrder_form" name="name_updateOrder_form" method="post" action ="<?php echo func::makeUrl('order', 'update', $iOrderId); ?>">
    <table class="addOrder_table">
        <tr>
            <th scope="row">ID</th>
            <td colspan="2"><?php echo $aRow['orderId']; ?></td>
        </tr>
        <tr>
            <th scope="row">Tên khách hàng</th>
            <td colspan="2"><?php echo $aCustomerRow['name']; ?>
                <input type="text" name="customerId" value="<?php echo $aRow['customerId']; ?>" hidden="true" />
                <input type="text" name="orderOldTotal" value="<?php echo $aRow['total']; ?>" hidden="true" />
                <input type="text" name="orderOldContent" value="<?php echo str_replace('"', SESSION_NAME, $aRow['content']); ?>" hidden="true" />
            </td>
        </tr>
        <tr>
            <th scope="row">Tên hàng hóa</th>
            <th scope="row">Số lượng (KG)</th>
            <th scope="row">Đơn giá (ngàn/KG)</th>
        </tr>
        <?php
            for($i=0; $i < ((count($aVals, 1) - 3) / 3); $i++){
                $iIdInvent = explode('.', $aVals['inventoryId'][$i]);
                $aInventory['inventoryId'][$i] = $iIdInvent[0];
                
                //inventory
                $sSql = 'SELECT inventoryId, title FROM inventory ORDER BY title ASC';
                $aResult = mysql::querySql($sSql);
        ?>
        <tr class="addOrder_field">
            <td class="addOrder_inventory">
                <select name="val[inventoryId][]">
                    <?php
                        while($aInventoryRow = mysql::fetchSql($aResult)){
                    ?>
                    <option <?php if($aInventoryRow['inventoryId'] == $aInventory['inventoryId'][$i]) echo 'selected'; ?> value="<?php echo $aInventoryRow['inventoryId'].'.'.$aInventoryRow['title']; ?>"><?php echo $aInventoryRow['title']; ?></option>
                    <?php
                        }
                        $aResult->free();
                    ?>
                </select>
            </td>
            <td class="addOrder_quantity"><input type="text" name="val[quantity][]" size="10" value="<?php echo func::numberFormat($aVals['quantity'][$i]); ?>" />x</td>
            <td class="addOrder_price"><input type="text" name="val[price][]" size="10" value="<?php echo func::numberFormat($aVals['price'][$i]); ?>" /></td>
        </tr>
        <?php
            }
        ?>
    </table>
    <table>
        <tr>
            <th scope="row">Giao hàng</th>
            <td><input type="checkbox" name="delivered" value="1" <?php if($aRow['delivered']) echo 'checked'; ?> /></td>
        </tr>
        <tr>
            <td colspan="2"><input type="button" name="addField" value="Thêm hàng hóa" /><input type="submit" name="updateOrderButton" value="Cập nhật đơn đặt hàng" /></td>
        </tr>
    </table>
</form>